// app.js
const useConst = require('const'); //常量js文件
const wx_auth = require('common/wx_auth') //wx授权js文件
const timestamp = parseInt(Date.parse(new Date()) / 10000); //时间戳
const version = "?v=1.562"; //版本号
//图片上传地址
const imgUrl = 'https://nqxxcx.whyimingkeji.com/resources/static/images/' 
import siteinfo from './siteinfo.js';
import util from './utils/util';

App({
  onLaunch() {
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })
  },
  globalData: {
    user_id: null,
  },
  useConst:useConst, //常用常量名
  wx_auth:wx_auth, 
  timestamp:timestamp,
  version:version,
  imgUrl: imgUrl,
  util:util,
  getShareUrlParams(params){
    let _this = this;
    return util.urlEncode(Object.assign({
      tg_id: _this.getUserId()
    }, params));
  },
  getUserId(){
    return wx.getStorageSync('user_id');
  },
  showSuccess(msg, callback) {
    wx.showToast({
      title: msg,
      icon: 'success',
      mask: true,
      duration: 1500,
      success() {
        callback && (setTimeout(function () {
          callback();
        }, 1500));
      }
    });
  },
  showError(msg, callback) {
    wx.showModal({
      title: '友情提示',
      content: msg,
      showCancel: false,
      success(res) {
      callback && callback();
      }
    });
  },
})



